﻿using RpcStore.DAL;
using RpcStore.RemoteModel.TransmitScheme.Model;
using WeDonekRpc.Client.Attr;
using WeDonekRpc.Client.Interface;
using WeDonekRpc.Model;

namespace RpcStore.Collect.LocalEvent
{
    [LocalEventName("Add")]
    internal class AddRpcMerEvent : IEventHandler<Model.RpcMerEvent>
    {
        private readonly IServerTransmitSchemeDAL _SchemeDAL;
        public AddRpcMerEvent (IServerTransmitSchemeDAL schemeDAL)
        {
            this._SchemeDAL = schemeDAL;
        }

        public void HandleEvent (Model.RpcMerEvent data, string eventName)
        {
            TransmitSchemeAdd[] adds = new TransmitSchemeAdd[]
            {
                new TransmitSchemeAdd
                {
                    IsAuto = true,
                    RpcMerId = data.RpcMer.Id,
                    Scheme = "RemoteLock",
                    Show="远程锁负载均衡方案",
                    SystemTypeId=1,
                    TransmitType= TransmitType.ZoneIndex
                },
                new TransmitSchemeAdd
                {
                    IsAuto = true,
                    RpcMerId = data.RpcMer.Id,
                    Scheme = "RpcTran",
                    Show="事务负载均衡方案",
                    SystemTypeId=1,
                    TransmitType= TransmitType.ZoneIndex
                },
                new TransmitSchemeAdd
                {
                    IsAuto = true,
                    RpcMerId = data.RpcMer.Id,
                    Scheme = "Accredit",
                    Show="授权码负载均衡方案",
                    SystemTypeId=1,
                    TransmitType= TransmitType.ZoneIndex
                }
            };
            this._SchemeDAL.Adds(adds);
        }
    }
}
